#include<iostream>
#include<string>
#include<memory>
//17.以独立语句将newed 对象置入智能指针
class Widget
{
    public:
    private:
};
int priority()
{
    return 0;
}
void processWidget(std::shared_ptr<Widget> pw, int priority)
{

}



int main()
{

    processWidget(std::shared_ptr<Widget> (new Widget), priority());//此时可能会有资源泄露风险
    //不确定编译器的调用顺序: new Widget shared_ptr() priority() 当priority第二顺序调用时,并出现异常时会导致new Widget指针异常
    //正确做法:
    std::shared_ptr<Widget> pw(new Widget);//此时编译器一定先执行new Widget 和 shared_ptr构造函数
    processWidget(pw, priority());
    return 0;
}